POV-Ray : Newsgroups : povray.programming : smooth triangle normals : Re: smooth triangle normals Server Time
28 Jul 2024 10:23:49 EDT (-0400)
  Re: smooth triangle normals  
From: Warp
Date: 5 May 2002 09:42:45
Message: <3cd536d5@news.povray.org>
WhiteGandalf <zus### [at] liberoit> wrote:
> could someone give me the mathematics needed to calculate the vertex 
> normals needed for the smooth_triangle primitive? i need to convert a "
> standard" triangle to a smooth one!

  You speak as if the vertex normals were unambiguous and there would be
just one correct solution.
  Of course there is an almost infinite amount of possible vertex normals
(not infinite, of course, as the size of the floating point numbers impose
a limit, but in theory), and one cannot say that one set of normals is
"more correct" than another. They can be whatever you want them to be.
  Also it's a mistake to think that the normal vector at a vertex shared
by several triangles should be same in all the triangles. If you want a
smooth lighting, it should, but it doesn't have to be (if the normal differs
in the adjacent triangles, it will give you an "edge" even though the
lighting of the triangles is smooth; this is sometimes a desired effect).

  Of course if what you want is to automatically calculate the normals
for a triangle mesh so that it gets completely smooth, you can do it
by averaging the triangle normals of all the triangles sharing the vertex.
  'Triangle normal' is the vector perpendicular to a triangle, calculated
with the cross-product of two edges of the triangle.
  Now, for each vertex point in the mesh take the triangle normals of all
the triangles sharing that vertex and calculate their average (ie. sum
the vectors and divide by the number of triangles).
  AFAIK the best result is got if you *don't* normalize the normal vectors
after the cross-product, but use them as they are. (The length of the vector
produced by the cross-product is the area of the triangle and this gives it
a good weight in the average.)

> PS: the release of a DXF to POV converter is near, the source already 
> quite works for my internal use win non-smoothed triangles. As soon as 
> my web-site server comes back I will put it online!

  If the DXF file doesn't have smooth triangles, then why would you want
to make them smooth? Not all meshes are smooth.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.